package com.example.mapper;

import com.example.pojo.Course;
import org.apache.ibatis.annotations.*;

import java.util.Vector;

@Mapper
public interface CourseMapper {

    @Select("select * from course order by id")
    Vector<Course> select();

    Vector<Course> selectCourse(String name, String state, String teacher);


    @Update("update course,course_select set name=#{name},creditHour=#{creditHour},period=#{period},classTime=#{classTime},classRoom=#{classRoom},intro=#{intro},state=#{state} where course.id=#{id} ")
    void update(Course course);

    @Delete("delete  from course  WHERE id=#{id}")
    void delete(String id);

    //@Insert("insert into course value (name=#{name},creditHour=#{creditHour},teacher=#{teacher},period=#{period}" +
      //      ",classTime=#{classTime},classRoom=#{classRoom},intro=#{intro},state=#{state},id=#{id})")
      @Insert(" INSERT INTO `instructional management`.course (name, teacher, creditHour, period, classTime, classRoom, intro, state,\n" +
              "                                               id)\n" +
              "VALUES (#{name}, #{teacher},#{creditHour}, #{period}, #{classTime}, #{classRoom}, #{intro}, #{state}, #{id});")
    void add(Course course);

      /*
      * 课程表查询
      * */
    @Select(" select course.id, course.name, course.teacher, course.credithour, course.period, course.classtime, course.classroom, course.intro, course.state from course_select,course where course=name and student=(select name from student where student.id=#{id})")
    Vector<Course> studentCourse(String id);
}
